<template>
    <div>
        <van-nav-bar title="歌手分类" left-arrow @click-left="onClickLeft" />
        <div class="line">
            <span v-for="(item,index) in languagetype" class="type_word" :class="{ type_word_select: item.id == select.area }" :key="index"
                @click="select.area = item.id">{{ item.name }}</span>
        </div>
        <div class="line">
            <span v-for="item,index in sextype" class="type_word" :class="{ type_word_select: item.id == select.type }"
                @click="select.type = item.id" :key="index">{{ item.name }}</span>
        </div>
        <div>热门歌手</div>
        <div v-for="item,index in artists" :key="index" v-lazy-container="{ selector: 'img'}" class="show_line" @click="gosheetdetail(item)">
            <img :data-src="item.picUrl" class="headimg">
            <Span>{{ item.name  }} &nbsp;</Span>
            <span v-if="item.alias[0]"> ({{ item.alias[0] }})</span>
        </div>
    </div>

</template>

<script setup>
import { ref, reactive ,onMounted ,watch} from 'vue'
import { useRouter  } from 'vue-router';
import  {singerApi} from '../../api/singer'
const onClickLeft = () => history.back();
const artists = ref([])
const router = useRouter()
let languagetype = ref([
    { name: '华语', id: '7' },
    { name: '日本', id: '8' },
    { name: '韩国', id: '16' },
    { name: '欧美', id: '96' },
    { name: '其他', id: '0' }
])
let sextype = ref([
    { name: '男', id: '1' },
    { name: '女', id: '2' },
    { name: '乐队/组合', id: '3' }
])
let select = reactive({
    area: '-1',
    type: '-1'
})
watch(select,(newval)=>{
    getsingerlist()
},{
    deep:true
})
onMounted(()=>{
    getsingerlist()
})
const getsingerlist =async()=>{
    let data =  await singerApi(select.type,select.area)
   console.log(data)
   artists.value = data.artists
}
const gosheetdetail = (item)=>{
    router.push({
        path: '/sheetdetail',
        query: {
            detail:JSON.stringify(item)
        }
    })
}
</script>

<style scoped>
.headimg{
    width: 50px;
    border-radius: 100%;
    height: 50px;
    margin:-20px 20px;
    /* position:absolute;
    top: 50%;
    transform: translateY(-50%); */
}
.type_word {
    margin: 20px;
}

.type_word_select {
    color: red;
}

.line {
    padding: 10px;
    background-color: white;
}
.show_line{
    position: relative;
    background-color: white;
    height: 70px;
    line-height: 70px;
}
</style> 